package com.business_clean.ui.adapter.format;

import android.view.View;
import android.widget.LinearLayout;

import com.business_clean.R;
import com.business_clean.data.mode.format.FormatItemList;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import org.jetbrains.annotations.NotNull;

public class FormatRowAdapter extends BaseQuickAdapter<FormatItemList, BaseViewHolder> {

    private String uuid = "";

    public FormatRowAdapter() {
        super(R.layout.item_format_row);
    }

    @Override
    protected void convert(@NotNull BaseViewHolder holder, FormatItemList item) {

        LinearLayout layout = holder.getView(R.id.ll_item_format);
        holder.setText(R.id.tv_item_format_row_name, item.getCat_name());

        if (uuid.equals(item.getId())) {
            holder.getView(R.id.view_indicate).setVisibility(View.VISIBLE);
            layout.setBackgroundResource(R.color.white);
        } else {
            holder.getView(R.id.view_indicate).setVisibility(View.INVISIBLE);
            layout.setBackground(null);
        }
    }

    public void updateItem(String uuid) {
        this.uuid = uuid;
        notifyDataSetChanged();
    }
}
